#include "reg3volumedatanode.h"
#include "reg3volumeattribwidget.h"
#include "../renderer/renderplugin.h"

using namespace PBVP;

Reg3DVolumeDataNode::Reg3DVolumeDataNode(Reg3DVolumeData *pData, MainInterface *mainInterface)
{
	m_pReg3Data = pData;
	m_pVolAttribWidget = new Reg3VolumeAttribWidget(this);
	float minExt[3], maxExt[3];
	pData->getMinMaxExt(minExt, maxExt);
	m_BBox.setMinimum(minExt[0], minExt[1], minExt[2]);
	m_BBox.setMaximum(maxExt[0], maxExt[1], maxExt[2]);
}

Reg3DVolumeDataNode::~Reg3DVolumeDataNode()
{
	delete m_pReg3Data;
}

QWidget* Reg3DVolumeDataNode::getPropertyWidget() const
{
	return m_pVolAttribWidget;
}

void Reg3DVolumeDataNode::render()
{
	
	if(!m_pRenderer) return;
	m_pRenderer->begin();
	m_pRenderer->render(this);
	m_pRenderer->end();
}

void Reg3DVolumeDataNode::setRenderer(RenderPlugin * pRenderer)
{
	DataNode::setRenderer(pRenderer);
	if(pRenderer && pRenderer->getRenderControl()) {
		m_pVolAttribWidget->setRenderingProperty(pRenderer->getRenderControl());
	}
}